/**
 * Bing每日一图插件安装脚本
 * 按照标准插件结构实现
 */

import pluginSystem from '../core/plugin-system.js'
import { Image } from 'lucide-react'

// 插件数据
const pluginData = {
  id: 'bing-daily-image',
  name: 'Bing每日一图',
  version: '1.0.1',
  description: '获取每日Bing图片并上传到存储桶',
  author: 'CS-Explorer',
  type: 'feature',
  category: 'utility',
  capabilities: [
    'ui:page',
    'ui:menu',
    'data:api',
    'network:http'
  ],
  permissions: [
    'network:http',
    'network:download',
    'filesystem:write'
  ],
  menu: {
    path: '/bing-daily-image',
    label: '每日一图',
    icon: 'Image',
    order: 10
  },
  defaultConfig: {
    autoDownload: true,
    uploadToBucket: true,
    bucketName: 'default-bucket'
  }
}

/**
 * 安装Bing每日一图插件
 */
async function installBingDailyImagePlugin() {
  try {
    console.log('开始安装Bing每日一图插件...')
    
    // 注册插件到系统
    const result = await pluginSystem.registerPlugin(pluginData)
    
    if (result.success) {
      console.log('Bing每日一图插件安装成功')
      
      // 初始化插件配置
      await pluginSystem.setPluginConfig(pluginData.id, pluginData.defaultConfig)
      
      return {
        success: true,
        message: '插件安装成功',
        pluginId: pluginData.id
      }
    } else {
      console.error('Bing每日一图插件安装失败:', result.error)
      return {
        success: false,
        error: result.error
      }
    }
  } catch (error) {
    console.error('安装Bing每日一图插件时发生错误:', error)
    return {
      success: false,
      error: error.message
    }
  }
}

export default installBingDailyImagePlugin
